package com.itheima.test6;

public class phoneTest {
    public static void main(String[] args) {
        //计算三部手机的平均价格
        //创建一个数组
        phone[] arr = new phone[3];

        //创建手机的对象
        phone p1 = new phone("小米",1999,"白色");
        phone p2 = new phone("huawei",4999,"heise");
        phone p3 = new phone("iphone",9999,"red");

        //把手机对象添加到数组中
        arr[0] = p1;
        arr[1] = p2;
        arr[2] = p3;

        //获取三部手机的平均价格
        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            //phone phone = arr[i];
            sum+=sum+arr[i].getPrice();
        }

        //求平均值
        int avg = sum/arr.length;

        System.out.println(avg);
    }
}
